﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Waiter.Common;
using DevComponents.DotNetBar;
using Waiter.Controler;
using Waiter.View;

namespace Waiter.CustomControl
{
    public partial class HeaderItem : UserControl
    {
        public HeaderItem()
        {
            InitializeComponent();
            ChangeColor(Waiter.Properties.Settings.Default.Style);
        }

        private void timerHeader_Tick(object sender, EventArgs e)
        {
            this.lblDate.Text = CommonUtils.fsFormatDate(CommonConstants.DDMMYYYY_HHMMSS, DateTime.Now);
            this.lblName.Text = CommonUtils.fsGetOPName();
        }

        public void init(String title, bool actionButton)
        {
            CommonLogging.fsWriteLog(CommonConstants.LOG_TYPE_INFO, "HeaderItem.init", "", "");

            this.lblTitle.Text = "<span align='center'>" + title + "</span>";
            this.timerHeader.Enabled = true;
            this.btnSwitchUser.Enabled = actionButton;
            this.btnChangeStyle.Enabled = actionButton;

            this.lblName.Text = CommonUtils.fsGetOPName();
        }

        private void btnSwitchUser_Click(object sender, EventArgs e)
        {
            CommonLogging.fsWriteLog(CommonConstants.LOG_TYPE_INFO, "HeaderItem.btnSwitchUser_Click", "", "");

            frmLogin frm = new frmLogin();
            frm.ShowDialog();
            this.lblName.Text = CommonUtils.fsGetOPName();         
        }

        private void buttonItem1_Click(object sender, EventArgs e)
        {
            ChangeColor(1);
        }

        private void buttonItem2_Click(object sender, EventArgs e)
        {
            ChangeColor(2);
        }

        private void buttonItem3_Click(object sender, EventArgs e)
        {
            ChangeColor(3);
        }

        private void buttonItem4_Click(object sender, EventArgs e)
        {
            ChangeColor(4);
        }

        private void buttonItem5_Click(object sender, EventArgs e)
        {
            ChangeColor(5);
        }

        private void buttonItem6_Click(object sender, EventArgs e)
        {
            ChangeColor(6);
        }

        private void buttonItem7_Click(object sender, EventArgs e)
        {
            ChangeColor(7);
        }

        private void buttonItem8_Click(object sender, EventArgs e)
        {
            ChangeColor(8);
        }

        private void buttonItem9_Click(object sender, EventArgs e)
        {
            ChangeColor(9);
        }

        private void buttonItem10_Click(object sender, EventArgs e)
        {
            ChangeColor(10);
        }

        private void btnChangeStyle_Click(object sender, EventArgs e)
        {
            ChangeColor(new Random().Next(1,10));
        }
        public void ChangeColor(int choice)
        {
            CommonLogging.fsWriteLog(CommonConstants.LOG_TYPE_INFO, "HeaderItem.ChangeColor", "", "");

            switch (choice)
            {
                case 1:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2007Blue;
                    break;
                case 2:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2007Silver;
                    break;
                case 3:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2007Black;
                    break;
                case 4:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2007VistaGlass;
                    break;
                case 5:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2010Silver;
                    break;
                case 6:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2010Blue;
                    break;
                case 7:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2010Black;
                    break;
                case 8:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Windows7Blue;
                    break;
                case 9:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.VisualStudio2010Blue;
                    break;
                case 10:
                    this.styleManagerWaiter.ManagerStyle = DevComponents.DotNetBar.eStyle.Metro;
                    break;
            }

            Waiter.Properties.Settings.Default.Style = choice;
            Waiter.Properties.Settings.Default.Save();
        }
    }
}
